<!DOCTYPE html>
<html>
<head>
    <title>处理器数据分析</title>
    <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
    <script type="text/javascript" src="https://assets.pyecharts.org/assets/echarts.min.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f5f5f5;
        }
        .header {
            background-color: #4CAF50;
            color: white;
            padding: 1rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 1rem;
        }
        .chart-container {
            background: white;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            padding: 1rem;
            margin-bottom: 2rem;
        }
        .chart {
            width: 100%;
            height: 400px;
        }
        .logout-btn {
            background: #f44336;
            color: white;
            border: none;
            padding: 0.5rem 1rem;
            border-radius: 4px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>处理器数据分析</h1>
        <div>
            <span>欢迎, {{ username }}</span>
            <a href="/logout" class="logout-btn">退出登录</a>
        </div>
    </div>

    <div class="container">
        <!-- 数据概览 -->
        <div class="chart-container">
            <h2>数据字段概览</h2>
            <div id="data_overview" class="chart"></div>
        </div>

        <!-- 年份分布 -->
        <div class="chart-container">
            <h2>不同年份发布的处理器数量</h2>
            <div id="year_distribution" class="chart"></div>
        </div>

        <!-- 设计商占比 -->
        <div class="chart-container">
            <h2>不同设计商的处理器数量占比</h2>
            <div id="designer_share" class="chart"></div>
        </div>

        <!-- 核心与数据速率 -->
        <div class="chart-container">
            <h2>处理器核心数量与最大数据速率的关系</h2>
            <div id="core_data_rate" class="chart"></div>
        </div>

        <!-- 时钟频率分布 -->
        <div class="chart-container">
            <h2>不同半导体技术的最大时钟频率分布</h2>
            <div id="clock_frequency" class="chart"></div>
        </div>

        <!-- 数据统计 -->
        <div class="chart-container">
            <h2>数据统计摘要</h2>
            <div id="data_stats" class="chart"></div>
        </div>
    </div>

    <script>
        // 初始化所有图表
        function initCharts() {
            {% for chart_id, chart_options in charts.items() %}
                var chart_{{ chart_id }} = echarts.init(document.getElementById('{{ chart_id }}'));
                chart_{{ chart_id }}.setOption({{ chart_options|safe }});
                window.addEventListener('resize', function() {
                    chart_{{ chart_id }}.resize();
                });
            {% endfor %}
        }

        // 页面加载完成后初始化图表
        document.addEventListener('DOMContentLoaded', initCharts);
    </script>
</body>
</html>